using UnityEngine;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class MobStoreage  {

	// Use this for initialization
	public static bool Initialized;
	public static List<NPC_Stats> mobs;

	public static NPC_Stats GetMobByID(int id)
	{
		if(!Initialized) Init();
		
		var mb =  from mob in mobs where mob.Id == id select mob;
		return (NPC_Stats) mb;
	}
	
	public static NPC_Stats GetMobByName(string Name)
	{
		if(!Initialized) Init();
		var mb = from mob in mobs where mob.Name == Name select mob;
		return (NPC_Stats) mb;
	}
	
	private static void Init()
	{
		using(var sm = File.OpenRead(Application.dataPath+"/GData/MobBase.gdt"))
		{
			mobs.Clear();
			while((sm.Position < sm.Length ))
			{
				NPC_Stats n = new NPC_Stats();
				n.Load(sm);
				mobs.Add(n);
			}
		}
		Initialized = true;
	}

}
